#pragma once
/*--------------------------------------------------------------------------------
 * Adaptive Intelligence - Foundation Framework Class Library
 * Version 2.00
 * 
 * System DLL Memory Cacher Class
 *      Caches the system 32 DLLs into memory.
 *------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------
 * System Imports
 *------------------------------------------------------------------------------*/
#include "stdafx.h"
using namespace System;
using namespace System::IO;
using namespace System::Runtime::InteropServices;
using namespace System::Collections;
using namespace System::Collections::Specialized;

namespace Adaptive
{
	namespace Foundation
	{
		namespace IO
		{
			/// <summary>
			/// Caches the system 32 DLLs into memory.
			/// </summary>
			public ref class SystemCacher
			{
			public:
				/*--------------------------------------------------------------------------------
				 * Public Event Definitions
				 *------------------------------------------------------------------------------*/
				#pragma region Public Event Definitions
				/// <summary>
				/// Occurs when the progress is upated.
				/// </summary>
				event EventHandler^ ProgressUpdate;
				#pragma endregion

				/*--------------------------------------------------------------------------------
				 * Constructor / Dispose / Destructor Methods
				 *------------------------------------------------------------------------------*/
				#pragma region Constructor / Dispose / Destructor Methods
				/// <summary>
				/// Initializes a new instance of the class.
				/// </summary>
				/// <remarks>
				/// This is the default constructor.
				/// </remarks>
				SystemCacher();
				/// <summary>
				/// Class destructor.
				/// </summary>
				~SystemCacher();
				#pragma endregion

				/*--------------------------------------------------------------------------------
				 * Public Properties
				 *------------------------------------------------------------------------------*/
				#pragma region Public Properties
				/// <summary>
				/// Gets the current progress percentage value.
				/// </summary>
				/// <value>
				/// A progress percentage value.
				/// </value>
				property int Progress { int get(); }
				#pragma endregion
 
				/*--------------------------------------------------------------------------------
				 * Public Methods / Functions
				 *------------------------------------------------------------------------------*/
				#pragma region Public Methods / Functions
				/// <summary>
				/// Cancels the current caching operation.
				/// </summary>
				/// <remarks>
				/// If an operation is in progress, calling this method will cause the operation to terminate.  
				/// This is included for asynchronous calls.
				/// </remarks>
				void Cancel();
				/// <summary>
				/// Caches the system32 DLLs into memory.
				/// </summary>
				/// <remarks>
				/// This causes the class to load the DLLs in the Windows system directory to memory.  This operation
				/// may be stopped by calling the <see cref="Cancel"/> method.
				/// </remarks>
				void CacheSystemDlls();
				/// <summary>
				/// Loads a specific DLL into memory.
				/// </summary>
				/// <param name="dllName">The fully-qualified path and name of the DLL to be cached.</param>
				/// <remarks>
				/// Caches the specified DLL into memory.
				/// </remarks>
				void LoadDll(String^ dllName);
				/// <summary>
				/// Gets a list of the DLLs in the system Win32 directory.
				/// </summary>
				/// <returns>
				/// A <see cref="StringCollection"/> instance containing the list of files names
				/// for all the DLLs in the Windows system directory.
				/// </returns>
				StringCollection^ GetSystemDlls();
				#pragma endregion

			protected:

				/*--------------------------------------------------------------------------------
				 * Protected Methods / Event Methods
				 *------------------------------------------------------------------------------*/
				#pragma region Protected Methods / Event Methods
				/// <summary>
				/// Raises the <see cref="ProgressUpdate"/> event.
				/// </summary>
				/// <param name="e">An <see cref="EventArgs"/> event arguments instance.</param>
				virtual void OnProgressUpdate(EventArgs^ e);
				#pragma endregion

			private:
				/*--------------------------------------------------------------------------------
				 * Private Member Declarations
				 *------------------------------------------------------------------------------*/
				#pragma region Private Member Declarations
				bool	_cancelFlag;
				int		_progress;
				#pragma endregion

			};
		}
	}
}